#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>

using namespace std;

class Solution {
public:
    bool vis[210][210] = { 0 };
    int dx[4] = { 0,0,1,-1 };
    int dy[4] = { 1,-1,0,0 };
    int n, m;
    int solve(vector<vector<char> >& grid) {

        n = grid.size(), m = grid[0].size();
        int ret = 0;
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < m; j++)
            {
                if (grid[i][j] == '1' && !vis[i][j])
                {
                    ret++;
                    vis[i][j] = true;
                    dfs(grid, i, j);
                }
            }
        }
        return ret;
    }

    void dfs(vector<vector<char> >& grid, int x, int y)
    {
        for (int i = 0; i < 4; i++)
        {
            int a = x + dx[i];
            int b = y + dy[i];
            if (a >= 0 && b >= 0 && a < n && b < m && !vis[a][b] && grid[a][b] == '1')
            {
                vis[a][b] = true;
                dfs(grid, a, b);
            }
        }
    }
};

int main()
{


	return 0;
}